<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<input type="test" name="" id="" value="" />
		<button type="button" class="set">存储数据</button>
		<button type="button" class="get">获取数据</button>
		<button type="button" class="remove">删除数据</button>
		<button type="button" class="del">清空所有数据</button>
	</body>

	<script type="text/javascript">
		var ipt = document.querySelector('input');
		var set = document.querySelector('.set');
		set.addEventListener('click', function() {
			var val = ipt.value;
			localStorage.setItem('uname', val);
			localStorage.setItem('zzzz', val);
		});

		var get = document.querySelector('.get');
		get.addEventListener('click', function() {
			console.log(localStorage.getItem('uname'));
		});

		var remove = document.querySelector('.remove');
		remove.addEventListener('click', function() {
			localStorage.removeItem('uname');
		});

		var del = document.querySelector('.del');
		del.addEventListener('click', function() {
			localStorage.clear();
		});
	</script>
</html>
